package com.qr.controller;

import com.qr.domain.Account;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@RequestMapping("/param")
@Controller
public class ParamDomainController {

    @RequestMapping("/saveAccount")
    public String saveAccount(Account account){
        System.out.println("执行了...");
        System.out.println(account);
        return "success";
    }

    /**
     * 获取原生Servlet原生API
     */
    @RequestMapping("/saveAccount1")
    public String testServlet(HttpServletRequest request, HttpServletResponse response){
        System.out.println(request);
        System.out.println(response);
        //我们可以从request中获取session
        HttpSession session = request.getSession();
        System.out.println(session);
        // session拿到最大的域对象
        ServletContext servletContext = session.getServletContext();
        return "success";
    }

}
